$(function(){
	$('#logo').click(function(){
		window.location = '/home'
	});
	
	$('.data-table').dataTable({
		"bJQueryUI": true,
		"sPaginationType": "full_numbers",
		"aaSorting": [[ 0, "desc" ]],
	});
	
	//Fix table formatting problems when resizing
	$('.data-table').attr("style", "");
	
	newUserGroupOption();
});

function newUserGroupOption(){
	$('#group-new-field').hide();
	$('#group-new-password').hide();	
	
	$("input[name='groupfields[option]']").change(function(){
		group_radios = $("input[name='groupfields[option]']:checked")
		if (group_radios.val() == 'existing'){
			$('#group-existing-chooser').show();
			$('#group-new-field').hide();
			$('#group-existing-password').show();
			$('#group-new-password').hide();
		} else if(group_radios.val() == 'new'){
			$('#group-existing-chooser').hide();
			$('#group-new-field').show();
			$('#group-existing-password').hide();
			$('#group-new-password').show();
		} else{
			
		}
	});
}

function expenseHelp() {
	window.open( '../expensehelp.html', 'Expense Help', 'status = 0, height = 300, width = 350, resizable = 0' )
}

function userHelp() {
	window.open( '../formhelp.html', 'User Help', 'status = 0, height = 300, width = 350, resizable = 0' )
}



function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function translateDOMName(id){
  var temp = new Array();
  temp = id.split('_');
  var output = "";
  
  for (var i=0; i<temp.length; i++){
    output = output + temp[i] + " ";
  }
  return output;
}

function toProper(str){
  return str.charAt(0).toUpperCase() + str.substring(1);
}
